Telegram Group & Telegram Channel
Slugify :

Converts a string to a URL-friendly slug.



Use str.lower() and str.strip() to normalize the input string.

Use re.sub() to to replace spaces, dashes and underscores with - and remove special characters
.

Code:


import re
def slugify(s):
s = s.lower().strip()
s = re.sub(r'[^\w\s-]', '', s)
s = re.sub(r'[\s_-]+', '-', s)
s = re.sub(r'^-+|-+$', '', s)
return s

EXAMPLE

slugify('Hello World!')

Output:
'hello-world'

Share and Support
@Python_Codes



tg-me.com/python_codes/142
Create:
Last Update:

Slugify :

Converts a string to a URL-friendly slug.



Use str.lower() and str.strip() to normalize the input string.

Use re.sub() to to replace spaces, dashes and underscores with - and remove special characters
.

Code:


import re
def slugify(s):
s = s.lower().strip()
s = re.sub(r'[^\w\s-]', '', s)
s = re.sub(r'[\s_-]+', '-', s)
s = re.sub(r'^-+|-+$', '', s)
return s

EXAMPLE

slugify('Hello World!')

Output:
'hello-world'

Share and Support
@Python_Codes

BY Python Codes


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_codes/142

View MORE
Open in Telegram


Python Codes Telegram | DID YOU KNOW?

Date: |

The messaging service and social-media platform owes creditors roughly $700 million by the end of April, according to people briefed on the company’s plans and loan documents viewed by The Wall Street Journal. At the same time, Telegram Group Inc. must cover rising equipment and bandwidth expenses because of its rapid growth, despite going years without attempting to generate revenue.

How Does Telegram Make Money?

Telegram is a free app and runs on donations. According to a blog on the telegram: We believe in fast and secure messaging that is also 100% free. Pavel Durov, who shares our vision, supplied Telegram with a generous donation, so we have quite enough money for the time being. If Telegram runs out, we will introduce non-essential paid options to support the infrastructure and finance developer salaries. But making profits will never be an end-goal for Telegram.

Python Codes from jp


Telegram Python Codes
FROM USA